package com.ikaros.utils;

import com.ikaros.enums.CodeEnum;
import com.ikaros.enums.OrderStatusEnums;
import java.lang.Enum;

/**
 * Created by Ikaros on 2017/11/12.
 */
public class EnumUtil {
    public static <T extends CodeEnum>T getByCode(Integer code, Class<T> enumClass){
        try {
            OrderStatusEnums.values();
            T[] enumConstants = enumClass.getEnumConstants();
            for (T t:enumConstants){
                if (t.getCode().equals(code)){
                    return t;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
       return null;
    }
}

